home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-06-18 | 2.1 KB | 95 lines | [TEXT/dosa] |
- // DesktopFolder.java : this is a Java source code file for the program Facade.
- // Copyright 1998, Andrew S. Downs
- // andrew.downs@tulane.edu
- //
- // This source code is distributed as freeware.
- // Just keep this author information in the file. Enjoy!
-
- import java.awt.*;
- import java.awt.event.*;
- import java.io.*;
- import java.util.*;
-
- public class DesktopFolder extends DesktopFrameItem implements Serializable, MouseListener, MouseMotionListener {
- boolean drag = false;
-
- int initialX = 0;
- int initialY = 0;
-
- // The folder icon is shared among all instances.
- static Image image;
-
- // For when this class implements its own drawing...
- Polygon rightArrowPolygon = new Polygon();
- Polygon downArrowPolygon = new Polygon();
-
- DesktopFolder() {
- super();
- this.addMouseListener( this );
- this.addMouseMotionListener( this );
- }
-
- public Polygon getRightArrowPolygon() {
- return this.rightArrowPolygon;
- }
-
- public Polygon getDownArrowPolygon() {
- return this.downArrowPolygon;
- }
-
- public Image getImage() {
- return image;
- }
-
- public static void setImage( Image i ) {
- image = i;
- }
-
- public void mouseDragged( MouseEvent e ) {
- if ( this.drag ) {
- this.setLocation( this.getBounds().x - this.initialX + e.getX(), this.getBounds().y - this.initialY + e.getY() );
- this.repaint();
- }
- }
-
- public void mouseMoved( MouseEvent e ) {
- }
-
- public void mouseEntered( MouseEvent e ) {
- }
-
- public void mouseExited( MouseEvent e ) {
- }
-
- public void mousePressed( MouseEvent e ) {
- if ( this.getBounds().contains( e.getPoint() ) ) {
- this.initialX = e.getX();
- this.initialY = e.getY();
- this.drag = true;
- return;
- }
- }
-
- public void mouseReleased( MouseEvent e ) {
- if ( this.drag ) {
- this.drag = false;
- this.repaint();
- }
- }
-
- public void mouseClicked( MouseEvent e ) {
- if ( e.getClickCount() == 2 ) {
- if ( !Desktop.windowExists( this.getPath() ) ) {
- DesktopFrame dw = new DesktopFrame( this.getPath() );
- dw.setLabel( this.getLabel() );
- dw.pack();
- dw.validate();
- dw.show();
- dw.toFront();
- dw.repaint();
- }
- }
- }
- }
-
-